package com.kiln.juxingqs.ui

import android.view.View
import androidx.navigation.fragment.NavHostFragment
import com.kiln.juxingqs.R
import com.kiln.juxingqs.BaseMiddleActivity
import com.kiln.juxingqs.databinding.ActivityDjzrBinding
import com.kiln.juxingqs.ui.vm.DjzrViewModel

//我的竞拍

class DjzrActivity :
    BaseMiddleActivity<DjzrViewModel, ActivityDjzrBinding>() {
    override fun getLayout(): Int {
        return R.layout.activity_djzr
    }

    override fun initViewModel(): DjzrViewModel = createViewModel()

    override fun initView() {
        binding.event = this
        binding.vm = viewModel

    }

    fun clickTab(index: Int) {
        updateTab(index)
    }

    fun updateTab(index: Int) {

        when (index) {
            0 -> {
                binding.oneTab.isSelected = true
                binding.twoTab.isSelected = false
                binding.threeTab.isSelected = false
                binding.one.visibility = View.VISIBLE
                binding.two.visibility = View.GONE
                (supportFragmentManager.findFragmentById(
                    R.id.fragment
                ) as NavHostFragment).navController.navigate(
                    R.id.oneTab
                )
            }
            1 -> {
                binding.oneTab.isSelected = false
                binding.twoTab.isSelected = true
                binding.threeTab.isSelected = false
                binding.one.visibility = View.GONE
                binding.two.visibility = View.VISIBLE
                (supportFragmentManager.findFragmentById(
                    R.id.fragment
                ) as NavHostFragment).navController.navigate(
                    R.id.twoTab
                )
            }
            2 -> {
                binding.oneTab.isSelected = false
                binding.twoTab.isSelected = false
                binding.threeTab.isSelected = true
                binding.one.visibility = View.GONE
                binding.two.visibility = View.VISIBLE
                (supportFragmentManager.findFragmentById(
                    R.id.fragment
                ) as NavHostFragment).navController.navigate(
                    R.id.threeTab
                )
            }
        }
    }

    override fun initData() {
        updateTab(intent.getIntExtra("index", 0))
    }

}